package com.example.weather;


import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;


public class MainActivity extends Activity implements OnClickListener {
    private WebView webView;
    @SuppressLint("MissingInflatedId")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        webView = (WebView)findViewById(R.id.webView1);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.setWebChromeClient(new WebChromeClient());
        webView.setWebViewClient(new WebViewClient());
        webView.loadUrl("https://tianqi.so.com/weather/101010100");
        webView.setInitialScale(57*4);

        Button bj=(Button)findViewById(R.id.bj);
        bj.setOnClickListener(this);

        Button gz=(Button)findViewById(R.id.gz);
        gz.setOnClickListener(this);
    }
    @Override
    public void onClick(View view){
        switch (view.getId()){
            case R.id.bj:
                openUrl("101010100");
                break;
            case R.id.gz:
                openUrl("101280101");
                break;
        }
    }
    private void openUrl(String id){
        webView.loadUrl("https://tianqi.so.com/weather/101010100"+ id +".shtml");
    }
}